<template>
	<el-container>
		<el-main>
			<redemption :commonPersonList="commonPersonList" />
			<openPeriod :commonPersonList="commonPersonList" />
			<fundType />
			<prodCalendar :commonPersonList="commonPersonList" />
			<prodType />
			<prodStatistics />
		</el-main>
		<fundList :fundComShow="fundComShow" @comIsShow="comIsShow" :fundList="fundList" ref="fundList" />
	</el-container>
</template>
<script>
import fundType from './components/fundType' // 基金类别组件
import prodCalendar from './components/prodCalendar' // 产品日历组件
import openPeriod from './components/openPeriod' // 临近开放期与临近赎回日组件
import prodType from './components/prodType' // 产品类别组件
import prodStatistics from './components/prodStatistics' // 产品统计组件
import redemption from './components/redemption' // 终止组件
import fundList from './components/fundList' // 提醒列表组件
import { checkisNext } from '@/api/productApi/home'
import { departmentUser } from '@/api/productApi/fundManager'
export default {
	name: 'Home',
	components: {
		fundType,
		prodCalendar,
		openPeriod,
		prodType,
		prodStatistics,
		redemption,
		fundList
	},

	data() {
		return {
			commonPersonList: [],
			fundComShow: false,
			fundList: []
		}
	},

	created() {
		this.getData()
	},

	mounted() {
		checkisNext().then(res => {
			if (res.msgCode === 'Y') {
				if (res.data.body.isNextOpenTimeNull === '2') {
					this.fundList = [...res.data.body.productFundInfos]
					this.fundList.forEach(item => {
						if (item.baseInfo) {
							item.fundCode = item.baseInfo.fundCode ? item.baseInfo.fundCode : ''
							item.fundFullName = item.baseInfo.fundFullName ? item.baseInfo.fundFullName : ''
						}
					})
					this.$nextTick(() => {
						this.comIsShow()
						setTimeout(() => {
							if (this.$refs.fundList) {
								this.$refs.fundList.spliceFunc()
							}
						})
					})
				}
			}
		})
	},

	methods: {
		// 获取数据
		async getData() {
			await departmentUser({ userCode: '2', userList: [] }).then(res => {
				if (res.msgCode === 'Y') {
					res.data.body.forEach(item => {
						item.ChineName = item.firstName ? item.firstName : item.username
					})
					this.commonPersonList = res.data.body
				}
			})
		},

		comIsShow() {
			this.fundComShow = !this.fundComShow
		}
	}
}
</script>
<style scoped  lang='scss' src='./index.scss'>
</style>
